package xyz.yq56.kafka_demo.mq;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;


@Component
@Slf4j
public class KafkaReceiver {

    @KafkaListener(topics = {"sun"},containerFactory = "kafkaListenerContainerFactory")
    public void process(List<ConsumerRecord<?,?>> records){
      if (!CollectionUtils.isEmpty(records)){
          for(ConsumerRecord<?,?> record:records){
              System.out.println(record.value());
          }
      }
    }

}
